Delivering Data to Users
SSAS
provides a great deal of flexibility for building scalable OLAP
solutions, but how do you present the data to users? The client-side
components deliver much of the functionality of SSAS, using the same
code base for the dimensional calculation engine, caching, and query
processing. You can use the Pivot Table Service to manage client/server
connections, and this is the layer for user interfaces to access SSAS
cubes through the OLE DB for OLAP interface. ADO MD provides an
application-level programming interface for development of OLAP
applications. Third-party tools and future versions of Microsoft Excel
(like 2007 and 2010) and other Microsoft Office products will use the
Pivot Table Service to access cubes.
The underlying Pivot
Table Service shares metadata with SSAS, so a request for data on the
client causes data and metadata to be downloaded to the client. The
Pivot Table Service determines whether requests need to be sent to the
server or can be satisfied at the client with downloaded data. If a
user requests sales information for the first quarter of 2008 and then
later decides to query that data for the first quarter of 2007 for
comparison, only the request for 2007 data has to go to the server to
get more data. The 2008 data is cached on the client.
Slices of data that are
retrieved to the client computer can also be saved locally for analysis
when the client computer is disconnected from the network. Users can
download the data in which they are interested and analyze it offline.
The Pivot Table Service can also create simple OLAP databases by
accessing OLE DB–compliant data sources.
With the ADO MD
interface, developers will be able to access and manipulate objects in
an SSAS database, enabling web-based OLAP application development.
Many independent software
vendors, such as Brio, Cognos, Business Objects, Micro Strategies, and
Hyperion, are working with Microsoft to leverage the rich features of
these OLAP services. They offer robust user interfaces that can access
SSAS’s cubes. Versions of Microsoft Office include the Pivot Table
Service to enable built-in analysis in tools such as Excel. It is
getting easier and easier to bring OLAP to the masses.
Multidimensional Expressions
The OLE DB for OLAP
specification contains MDX syntax that is used to build datasets from
cubes and is used to define cubes themselves. Developers of OLE DB OLAP
providers can map MDX syntax to SQL statements or native query
languages of other OLAP servers, depending on the storage techniques.
MDX statements build
datasets by using information about cubes from which the data will be
read. This includes the number of axes to include, the dimensions on
each axis and the level of nesting, the members or member tuples and
sort order of each dimension, and the dimension members used to filter,
or slice, the data. (Tuples are combinations of dimensions such as time and product time that present multidimensional data in a two-dimensional dataset.)
An MDX statement has four basic parts:
Member scope information, using the WITH MEMBER clause
Dimension, measure, and axis information in the SELECT clause
The source cube in the FROM clause
Dimension slicing in the WHERE clause
Expressions in an MDX statement operate on numbers, strings, members, tuples, and sets. Numbers and strings mean the same thing here as they do in other programming contexts. Members are the values in a dimension, and levels are groups of members. Sets
are collections of tuple elements to further combine facts. If the
dimension were time, a particular year, quarter, or month would be a
member, and month values would belong to the month level. You use the
dimension browser in SSAS to view members of a dimension.
The following example shows an MDX SQL expression:
WITH MEMBER [Measures].[Total Sales Units]
AS 'Sum([Measures].[Sales Units])'
SELECT
{[Measures].[Total Sales Units]} ON COLUMNS,
{Topcount([Product_Dimension].[SKU].members,100,
[Measures].[Total Sales Units])}
ON ROWS
FROM [Comp Sales]
WHERE ([Time_Dimension].[All Time])
You can download this simple query against the Comp Sales cube from Sams Publishing at www.samspublishing.com, and it is on the CD for this book as well. This query returns the sums of the sales units for products for all time periods. Figure 45
shows the full execution of this query within a query window of SSMS.
Notice that the metadata for the cube is also made available in the
center pane of SSMS, along with an MDX Functions tab that provides all
the MDX functions that can be used. This feature is very helpful for
building valid MDS queries within this environment. Also notice that
the result set display area is very specialized in order to display
multidimensional results.
This simple MDX statement
shows the basic parts of a working query. In this case, measures are
displayed in columns, and the product dimension members make up the
axes of this multidimensional query and are displayed in rows. The
display of multiple dimensions in rows like this is how the term tuple is used in the context of SSAS.
ADO MD
ADO MD is an easy-to-use
access method for dimensional data via an OLE DB for OLAP provider. You
can use ADO MD in Visual Basic, Visual C++, and Visual J++. Like ADO,
ADO MD offers a rich application development environment that can be
used for multitier client/server and web application development.
You
can retrieve information about a cube, or metadata, and execute MDX
statements by using ADO MD to create cellsets to return interesting
data to a user. ADO MD is another subject too broad to cover in detail
in this article. Specifications for OLE DB for OLAP and ADO MD are
available on the Microsoft website at http://msdn2.microsoft.com/en-us/library/ms126037.aspx.